﻿using System.Collections.Generic;
using OpenWaves.Pagination;

namespace OpenWaves.Web.Pagination
{
    public static class EnumerableExtensions
    {
        public static PaginationViewModel<T> Paginate<T>(this IEnumerable<T> items, int pageSize, int currentPageIndex, int maxNumberOfPagesToShow = 5)
        {
            int totalItemsCount;
            var pages = items.Paginate(pageSize, out totalItemsCount);
            return PaginationViewModel.Create(totalItemsCount, pages, currentPageIndex, maxNumberOfPagesToShow);
        }
    }
}